package com.xian.java.stream;

import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class MapTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        //DataStreamSource<String> stringDataStreamSource = env.readTextFile("E:/test/Temperature.txt");
        DataStream<String> dataStream = env.readTextFile("E:/test/Temperature.txt"); //用父类接
        //dataStream.print();

        //获取温度字符串的id字段
        //SingleOutputStreamOperator<String> map = dataStream.map(new RichMapFunction<String, String>() {
        DataStream<String> map = dataStream.map(new RichMapFunction<String, String>() {  //用父类接
            @Override
            public String map(String value) throws Exception {
                return value.split(",")[0];
            }
        });

        map.print();



        env.execute();


    }
}
